package com.example.examsystem.model;

import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 角色实体
 */
@Entity
@Table(name = "roles")
@Data
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public class Role {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 角色名称
     */
    @Column(name = "name", nullable = false, unique = true, length = 50)
    private String name;
    
    /**
     * 角色显示名称
     */
    @Column(name = "display_name", length = 100)
    private String displayName;
    
    /**
     * 角色描述
     */
    @Column(name = "description", length = 500)
    private String description;
    
    /**
     * 角色状态：0-禁用，1-启用
     */
    @Column(name = "status", nullable = false)
    private Integer status = 1;
    
    /**
     * 是否为系统内置角色
     */
    @Column(name = "is_system", nullable = false)
    private Boolean isSystem = false;
    
    /**
     * 排序
     */
    @Column(name = "sort")
    private Integer sort = 0;
    
    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
}





